//
//  MeHeaderView.m
//  LingQian
//
//  Created by wtjr on 2018/1/22.
//  Copyright © 2018年 xieyingze. All rights reserved.
//

#import "MeHeaderView.h"

@interface MeHeaderView()

@property (nonatomic, strong) UIView *mainView;

@end

@implementation MeHeaderView

#pragma mark - Init

- (void)initData {
    
}

- (void)initSubViews {
    [self addSubview:self.mainView];
}

- (void)autoLayoutSubViews {
    [self.mainView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(@0);
    }];
}

#pragma mark - BaseMethod


#pragma mark - Interface


#pragma mark - Delegate


#pragma mark - TouchEvent


#pragma mark - Setter

- (void)setOffset:(CGFloat)offset {
    if (offset <=0) {
        self.mainView.backgroundColor = [kCOLOR_tableView colorWithAlphaComponent:0];
    } else {
        CGFloat alpha = offset >= 64 ? 0.9 : (offset/64) * 0.9;
        self.mainView.backgroundColor = [kCOLOR_tableView colorWithAlphaComponent:alpha];
    }
}

#pragma mark - Getter

- (UIView *)mainView {
    if (!_mainView) {
        _mainView = [UIView new];
        _mainView.backgroundColor = kCOLOR_clear;
        
        BaseImageView *headerImageView = [BaseImageView new];
        headerImageView.imageName = @"home_header";
        headerImageView.layer.cornerRadius = 25;
        headerImageView.layer.masksToBounds = YES;
        [_mainView addSubview:headerImageView];
        [headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@30);
            make.centerY.equalTo(@0).offset(10);
            make.width.height.equalTo(@50);
        }];
        
        BaseLabel *nameLabel = [BaseLabel new];
        [nameLabel setLabelShadow];
        [nameLabel setLabelStyle:@"xieyingze" textColor:KCOLOR_nornalFont textFont:kFONT_mainFont(20) texrAlignment:NSTextAlignmentLeft];
        [_mainView addSubview:nameLabel];
        [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(headerImageView.mas_right).offset(10);
            make.centerY.equalTo(headerImageView);
            make.height.equalTo(@30);
        }];
    }
    return _mainView;
}

@end
